package com.example.lock.controller;

import com.example.lock.service.DistributeLockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
public class TestController {

    @Autowired
    private DistributeLockService distributeLockService;

    @GetMapping("/")
    public long getServerTime() {
        try {
            distributeLockService.getLockForOneSeconds(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
            return System.currentTimeMillis();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return -1L;
    }
}